package com.xpj.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class AsyncAspect {

    @Pointcut("@annotation(com.xpj.annotation.MyAsync)")
    public void pointcut() {
    }


    @Around(value = "pointcut()")
    public void around(ProceedingJoinPoint joinPoint) {

        new Thread(() -> {
            try {
                joinPoint.proceed();
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
        }).start();
    }
}
